<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>投诉管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="resources/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="resources/css/public.css" media="all"/>
</head>
<body class="childrenBody">
<form class="layui-form">
    <blockquote class="layui-elem-quote quoteBox">
        <form class="layui-form">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    投诉用户电话：<input type="text" class="layui-input telVal" placeholder="请输入用户电话"/>
                </div>
                <div class="layui-input-inline">
                    投诉内容：<input type="text" class="layui-input resultVal" placeholder="请输入投诉内容"/>
                </div>
                <div class="layui-input-inline">
                    处理状态：<input type="text" class="layui-input statusVal" placeholder="请输入处理状态"/>
                </div>
                <a class="layui-btn search_btn" data-type="reload">搜索</a>
            </div>
        </form>
    </blockquote>
    <table id="faceBacktable" lay-filter="faceBacktable"></table>
</form>
<script type="text/javascript" src="resources/layui/layui.js"></script>
<script type="text/javascript" th:inline="none">
    layui.use(['form', 'layer', 'table', 'laytpl'], function () {
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laytpl = layui.laytpl,
            table = layui.table;
        //用户列表
        var tableIns = table.render({
            elem: '#faceBacktable',
            url: 'TFSelectByPage.do', //? left join
            cellMinWidth: 95,
            page: true,
            height: "full-200",
            limits: [10, 15, 20, 25],
            limit: 10,
            id: "faceBacktablezz",
            cols: [[
                {type: "checkbox", fixed: "left", width: 50},
                {field: 'perFeedbackId', title: '编号', minWidth: 100, align: "center"},
                {field: 'perUserName', title: '投诉用户', minWidth: 100, align: "center",templet:'#aa'},
                {field: 'perUserTel', title: '联系方式', align: 'center'},
                {field: 'perFeedbackStatus', title: '投诉状态', align: 'center'},
                {field: 'perFeedbackDetails', title: '投诉内容', align: 'center'},
                {field: 'perFeedbackResult', title: '处理结果', align: 'center'},
                {title: '操作', field: 'perFeedbackStatus', fixed: "right", align: "center",templet:function (obj) {
                        if (obj.perFeedbackStatus=="已处理"){
                            return ' <a class="layui-btn layui-btn-xs layui-btn-primary" id="perFacebackBar" lay-event="deal">已处理</a>';
                        }else if (obj.perFeedbackStatus=="未处理"){
                            return ' <a class="layui-btn layui-btn-xs layui-btn-warm" id="perFacebackBar" lay-event="deal">处理投诉</a>';
                        }
                    }}
            ]],
            done:function () {
               // window.onload=findUser();
            }
        });
        //实现搜索功能
        $(".search_btn").click(function () {
            var perUserTel = $(".telVal").val();
            var perFeedbackResult=$(".resultVal").val();
            var perFeedbackStatus=$(".statusVal").val();
            table.reload('faceBacktablezz', {
                where: {
                    perUserTel:perUserTel,
                    perFeedbackResult:perFeedbackResult,
                    perFeedbackStatus:perFeedbackStatus
                }
            });
        });

        //tool(xx)这里的xx是和上边表个的lay-filter="userList"对应的
        table.on("tool(faceBacktable)", function (obj) {
            //获取当前行的数据
            var data = obj.data;
            switch (obj.event) {
                case 'deal' :
                    dealComplain(data);
                    break;
            }
        });

        function dealComplain(data) {
           if (data.perFeedbackStatus=="未处理"){
               var index = layer.open({
                   type: 2,
                   title: "处理投诉",
                   content: "toDealComplain.do",
                   area: ['650px', '350px'],
                   success: function (layero, index) {
                       var body = layer.getChildFrame('body', index);//少了这个是不能从父页面向子页面传值的
                       body.contents().find("#serviceIdHiden").val(data.perFeedbackId);//这样就将值传递给子页面中id为serviceIdHiden的隐藏域
                       body.contents().find(".perUserTel").val(data.perUserTel);
                   }
               });
               window.sessionStorage.setItem("index", index);
               //改变窗口大小时，重置弹窗的宽高，防止超出可视区域（如F12调出debug的操作）
               $(window).on("resize", function () {
                   layui.layer.full(window.sessionStorage.getItem("index"));
               })
           }
        }

        // function findUser() {
        //     var data=layui.table.cache["faceBacktablezz"];//获取表格所有值
        //     var uIds = [];
        //     if (data.length > 0) {
        //         for (var i in data) {
        //             uIds.push(data[i].perUserId);
        //         }
        //         console.log(uIds);
        //         $.ajax({
        //             url: "/findUserName.do",
        //             data: {ids: uIds},
        //             type: "POST",
        //             dataType: "json",
        //             success: function (res) {
        //                 // var tu=res.data
        //                 for(var x=0;x<res.length;x++){
        //
        //                     console.log(res[x].tperUser.perUserName);
        //
        //                 }
        //
        //             }
        //         });
        //
        //     }
        //
        // }
    });

</script>
<script id="aa" type="text/html">
    {{d.tperUser.perUserName}}
</script>
</body>
</html>

